package com.lehuowujie.lehuomarket.ui.login;

import android.app.Activity;

/**
 * Created by 王瑞铭 on 2017/1/13.
 */
public class ILoginPresenterImpl implements ILoginPresenter {

    private ILoginModel mILoginModel;

    private ILoginView mILoginView;

    public ILoginPresenterImpl(ILoginView iLoginView)
    {
        this.mILoginView = iLoginView;
        this.mILoginModel = new ILoginModelImpl();
    }

    @Override
    public void login(Activity activity) {
        mILoginView.showLoadingProgress();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {

        }
        ILoginModelImpl.OnLoginListener listener = new ILoginModelImpl.OnLoginListener() {
            @Override
            public void onError(String errorMessage) {
                mILoginView.hideLoadingProgress();
                mILoginView.onError(errorMessage);
            }

            @Override
            public void onSuccess() {
                mILoginView.hideLoadingProgress();
                mILoginView.onLoginSuccess();
            }
        };
        mILoginModel.login(activity,listener);
    }
}
